package foundation.common.util;

import java.util.Date;
import java.util.regex.Pattern;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.zkoss.zhtml.Messagebox;
import org.zkoss.zk.ui.ComponentNotFoundException;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.Path;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.Include;
import org.zkoss.zul.Tab;
import org.zkoss.zul.Tabpanel;
import org.zkoss.zul.Tabpanels;
import org.zkoss.zul.Tabs;

import foundation.web.flow.AbstractNavigationComposer;
import foundation.web.flow.ComposerStateHolder;
import foundation.web.flow.Flow;
import foundation.web.flow.FlowStep;
import ar.com.sne.SNeUtil;
import ar.com.sne.bean.BaseBO;
import ar.com.sne.cfg.ImgLocator;
import ar.com.sne.util.DateUtil;
import ar.com.sne.util.StringUtil;

/**
 * @author hernan
 * 
 */
public abstract class CommonWebUtil {

	private static final long serialVersionUID = 4873428462167843238L;
	

	/**************************************************************************************
	 * START KEY SESSION	
	 */	
	public static final String VERTICAL_MENU="verticalMenu";
	public static final String CONTENIDO_PRINCIPAL = "contenidoPrincipal";
	public static final String CONTENIDO_MENU = "menus";
	public static final String MAIN_PAGE_NAME = "pagebasetemplate";
	
	public static final String ARGS = "ARGS";
	public static final String OBJECT_TO_EDIT_ARGUMENT = "objectToedit";
	public static final String CALLBACK_ARGUMENT = "callback";
	public static final String CALLBACK_VALIDATION = "callbackValidation";
	public static final String LIST_TO_PRINT = "listaToPrint";
	public static final String SRC_REPORT_TO_PRINT = "srcReportToPrint";
	public static final String PARAMETERS_TO_PRINT = "parametersToPrint";
	public static final String EVENT_REPORT_TO_PRINT = "eventReportToPrint";
	public static final String EVENT_SHEET_REPORT_TO_PRINT = "eventSheetReportToPrint";
	
	public static final String DESTINATION_KEY="destinationKey";
	public static final String DESTINATION_OBJECT_ID="destinationObjectId";
	public static final String DESTINATION_OBJECT_CLASS="destinationClassObject";
	public static final String DESTINATION_PARAMETERS="destinationParameters";


	
	final static String PATHMACROS = "/macros/";
	final static String CONFIGREPORT = "reporte.properties";
	final static String REPORT_PROPERTIES ="reportProperties";
	
	final static String CONFIGDESTINATION = "destinations.properties";
	final static String DESTINATION_SESSION_KEY ="destinationProperties";
	public final static String COMPOSER_PARENT ="composerparent";
	
	/**************************************************************************************
	 * END KEY SESSION
	 */
	
	private static final Log log = LogFactory.getLog(CommonWebUtil.class);

	
	public static Pattern EMAIL_PATTERN = CommonGeneralUtil.EMAIL_PATTERN;
	
	
	public static Object removeParameter(String key){
		Flow flow = (Flow)Executions.getCurrent().getDesktop().getAttribute(Flow.class.getSimpleName());		
		return flow.removeAtribute(key);
	}
	
	public static Object getParameter(String key){
		Flow flow = (Flow)Executions.getCurrent().getDesktop().getAttribute(Flow.class.getSimpleName());
		if(flow!=null)
			return flow.getAtribute(key);
		else
			return null;
	}
	
	public static void putParameter(String key, Object value){
		Flow flow = (Flow)Executions.getCurrent().getDesktop().getAttribute(Flow.class.getSimpleName());
		flow.putAtribute(key,value);
	}
	
	public static Flow getCurrentFlow(){
		Flow flow = (Flow)Executions.getCurrent().getDesktop().getAttribute(Flow.class.getSimpleName());
		return flow;
	}
	
	
//	public static void back(){
//		Flow flow = (Flow)Executions.getCurrent().getDesktop().getAttribute(Flow.class.getSimpleName());
//		FlowStep step = flow.pop();
//		if(step!=null){
//			flow.setCurrentStep(step);		
//			redirecToUrl(step.getUrl());	
//		}
//		else{
//			backToSelectMenu();
//		}
//		
//	}
//	
//	public static void backToSelectMenu(){
//		//si el paso anterior es nulo, entonces por defecto vuelve al submenu selecciondo actualmente
//		//si se crea un nuevo Flow, como si hubiera clickeado en el subMenu
//		String nextUrl="";
//		Tree tree = (Tree) Path.getComponent("//"
//				+ CommonWebUtil.MAIN_PAGE_NAME + "/"
//				+ CommonWebUtil.VERTICAL_MENU);
//		
//		List<Treeitem> listaMenu = new ArrayList<Treeitem>(tree.getFirstChild().getChildren());
//		for (Treeitem menuTreeItem :listaMenu) {
//			List<Treeitem> listaSubMenu= new ArrayList<Treeitem>(menuTreeItem.getLastChild().getChildren());
//			for(Treeitem subMenuTreeItem:listaSubMenu){
//				if(subMenuTreeItem.isSelected()){
//					Treecell treecellHijo = (Treecell)subMenuTreeItem.getFirstChild().getFirstChild();						
//					SubMenu subMenu=MenuComposer.getSubMenu(treecellHijo.getId());
//					nextUrl=subMenu.getPath();
//				}				
//			}
//		}
//		
//		if(!StringUtil.isNullOrEmpty(nextUrl)){
//			forward(nextUrl);
//		}
//	}
	
//	public static SubMenu getSelectMenu(){
//		Tree tree = (Tree) Path.getComponent("//"
//				+ CommonWebUtil.MAIN_PAGE_NAME + "/"
//				+ CommonWebUtil.VERTICAL_MENU);
//		
//		List<Treeitem> listaMenu = new ArrayList<Treeitem>(tree.getFirstChild().getChildren());
//		for (Treeitem menuTreeItem :listaMenu) {
//			List<Treeitem> listaSubMenu= new ArrayList<Treeitem>(menuTreeItem.getLastChild().getChildren());
//			for(Treeitem subMenuTreeItem:listaSubMenu){
//				if(subMenuTreeItem.isSelected()){
//					Treecell treecellHijo = (Treecell)subMenuTreeItem.getFirstChild().getFirstChild();						
//					SubMenu subMenu=MenuComposer.getSubMenu(treecellHijo.getId());
//					return subMenu;
//				}				
//			}
//		}
//		return null;
//	}
	
//	public static void backTo(String urlTo){		
//		Flow flow = (Flow)Executions.getCurrent().getDesktop().getAttribute(Flow.class.getSimpleName());
//		FlowStep step = flow.popTo(urlTo);
//		if(step!=null){
//			flow.setCurrentStep(step);	
//			redirecToUrl(getProperty("paginaBlanco"));
//			redirecToUrl(step.getUrl());	
//		}
//		else{
//			backToSelectMenu();
//		}
//		
//	}
	
	public static void forward(String nextUrl, AbstractNavigationComposer composerCurrent){
		//agrega en el flow actual un nuevo paso, con namecomposerCurren y args.
		
		//PASO 1 --> Generar es state del composer;
		ComposerStateHolder composerState = new ComposerStateHolder();
		composerState.getState(composerCurrent);
		Flow flow = (Flow)Executions.getCurrent().getDesktop().getAttribute(Flow.class.getSimpleName());
		flow.push(nextUrl, composerState);
		redirecToUrl(getProperty("paginaBlanco"));
		redirecToUrl(nextUrl);		
	}
	
	public static void forward(String url){	
		//aca borra el flow actual si es que existia
		//y crea un nuevo flow con la url actual en uns stack
		//Creo un nuevo flow
		//borra la variable en session que se utiliza para el filtro busqueda macro.
		Executions.getCurrent().getDesktop().removeAttribute("composer");
		Flow flow = new Flow(url);	
		Executions.getCurrent().getDesktop().setAttribute(Flow.class.getSimpleName(), flow);
		redirecToUrl(getProperty("paginaBlanco"));
		redirecToUrl(url);
	}
	
	public static void forward(String url, String firstParameterKey,Object firstParameterValue){	
		//aca borra el flow actual si es que existia
		//y crea un nuevo flow con la url actual en uns stack y guarda en el los primeros parametros en session
		//Creo un nuevo flow
		Flow flow = new Flow(url);
		Executions.getCurrent().getDesktop().setAttribute(Flow.class.getSimpleName(), flow);
		putParameter(firstParameterKey, firstParameterValue);
		redirecToUrl(getProperty("paginaBlanco"));
		redirecToUrl(url);
	}
	
	public static void newFlow(String urlInitial){	
		//aca borra el flow actual si es que existia
		//y crea un nuevo flow con la url actual en uns stack
		//Creo un nuevo flow
		Flow flow = new Flow(urlInitial);
		Executions.getCurrent().getDesktop().setAttribute(Flow.class.getSimpleName(), flow);		
	}
			
	public static void restoreComposer(AbstractNavigationComposer composerCurrent){		
		try {
			
			Flow flow = (Flow)Executions.getCurrent().getDesktop().getAttribute(Flow.class.getSimpleName());
			FlowStep step = flow.getCurrentStep();
			if(step!=null){				
				ComposerStateHolder state =(ComposerStateHolder)step.getStateHolder();
				if(state.getComposerName().equals(composerCurrent.getClass().getSimpleName())){
					state.setState(composerCurrent);
					composerCurrent.setBack(true);
					flow.setCurrentStep(null);
				}
			}
			
		}catch (Exception e) {
			log.error(e.getMessage());
		}			
	
	}
	
	public static Page  getMainPage(){		
		return (Page) Path.getComponent("//"+ CommonWebUtil.MAIN_PAGE_NAME);
	}
	
	/**
	 * Creates a page from a zul-file in a tab in the center area of the
	 * borderlayout. Checks if the tab is opened before. If yes than it selects
	 * this tab.
	 * 
	 * @autor Terry Tornado
	 * @param zulFilePathName
	 *            The ZulFile Name with path.
	 * @param tabName
	 *            The tab name.
	 * @throws InterruptedException
	 */
	public static void forwardPage(String zulFilePathName, String tabName, String tabLabel){

		String funcName = SNeUtil.currentMethodName();
		if (log.isDebugEnabled()) log.debug(funcName + ": enter");
		
		Executions.getCurrent().getDesktop().removeAttribute("composer");
		Flow flow = new Flow(zulFilePathName);	
		Executions.getCurrent().getDesktop().setAttribute(Flow.class.getSimpleName(), flow);
		
		try {
			int workWithTabs = 1;

			if (workWithTabs == 1) {

				/* get an instance of the borderlayout defined in the zul-file */
				Borderlayout bl = (Borderlayout) Path.getComponent("/mainBorderLayout");
				/* get an instance of the searched CENTER layout area */
				Center center = bl.getCenter();
				// get the tabs component
				Tabs tabs = (Tabs) center.getFellow("tabBoxIndexCenter").getFellow("tabsIndexCenter");
				/**
				 * Check if the tab is already opened than select them and<br>
				 * go out of here. If not than create them.<br>
				 */

				Tab checkTab = null;
				try {
					// checkTab = (Tab) tabs.getFellow(tabName);
					checkTab = (Tab) tabs.getFellow("tab_" + tabName.trim());
					checkTab.setSelected(true);
				} catch (ComponentNotFoundException ex) {
					// Ignore if can not get tab.
				}
				if (checkTab == null) {

					Tab tab = new Tab();
					tab.setId("tab_" + tabName.trim());
					tab.setLabel(tabLabel.trim());
					tab.setImage(ImgLocator.getImageSrc(tabName.trim()));
					tab.setClosable(true);
					tab.setParent(tabs);
					
					Tabpanels tabpanels = (Tabpanels) center.getFellow("tabBoxIndexCenter").getFellow("tabsIndexCenter")
							.getFellow("tabPanelsIndexCenter");
					Tabpanel tabpanel = new Tabpanel();
					tabpanel.setHeight("100%");
					tabpanel.setWidth("100%");
					tabpanel.setStyle("padding: 0px; overflow:auto");
					tabpanel.setParent(tabpanels);
					

					/*
					 * create the page and put it in the tabs area
					 */
					Executions.createComponents(zulFilePathName, tabpanel, null);
					tab.setSelected(true);

				}
			} else {
				/* get an instance of the borderlayout defined in the zul-file */
				Borderlayout bl = (Borderlayout) Path.getComponent("/mainBorderLayout");
				/* get an instance of the searched CENTER layout area */
				Center center = bl.getCenter();
				/* clear the center child comps */
				center.getChildren().clear();
				/*
				 * create the page and put it in the center layout area
				 */
				Executions.createComponents(zulFilePathName, center, null);
			}

			if (log.isDebugEnabled()) {
				log.debug("Llamando zul-file: " + zulFilePathName);
			}
		
		
		} catch (Exception e) {
			throwErrorMassage(e.toString(),"Error", null);
			System.out.println(e.toString());
		}
	}
	
	public static Object getService(String bean) {
		return CommonGeneralUtil.getService(bean);
	}
	
	
	private static void redirecToUrl(String url){
		
		long startTime = System.currentTimeMillis();
		Include include = (Include) Path.getComponent("//"
			+ CommonWebUtil.MAIN_PAGE_NAME + "/"
			+ CommonWebUtil.CONTENIDO_PRINCIPAL);
		include.setSrc(url);	
	
	if (log.isDebugEnabled()){
		long time = System.currentTimeMillis() - startTime;
		StringBuilder sb = new  StringBuilder(250);
		sb.append("Elapsed Time : ");
		sb.append(time);
		sb.append(" - forwarding to: ");
		sb.append(url);
		log.debug(sb);
		}
	}
	
	
	public static String getProperty(String property) {
		return org.zkoss.util.resource.Labels.getLabel(property);
	}
	
	public static String getProperty(String property,String[] parameters) {
		return org.zkoss.util.resource.Labels.getLabel(property,parameters);
	}

	public static String booleanToStringFormat(Boolean value) {
		String bool ="";
		if(value!=null && value)
			bool=CommonWebUtil.getProperty("label.boolean.si");
		else if(value==null || (value!=null && !value))
			bool=CommonWebUtil.getProperty("label.boolean.no");			
		return bool;	
	}
	
	
	public static String fechaToStringFormat(Date fecha) {
		String dateString="";
		if(fecha!=null)
			dateString = DateUtil.formatDate(fecha, DateUtil.ddSMMSYYYY_MASK);	
		return dateString;		
	}
	

	public static void throwGenericSuccessMassage(){
		throwSuccessMassage(null, null, null);
	}
	
	public static void throwGenericSuccessMassage(EventListener callback){
		throwSuccessMassage(null, null, callback);
	}
	public static void throwConfirmDelete(String descripcionObjectToDelete, final EventListener eventListener)
	{

		try{
		StringBuilder message = new StringBuilder();
		message
				.append(CommonWebUtil
						.getProperty("AbstractCRUDManagerComposer.confirm.delete.window.message"));
		message.append(" ");
		message.append(descripcionObjectToDelete);
		
		Messagebox
				.show(
						message.toString(),
						CommonWebUtil
								.getProperty("AbstractCRUDManagerComposer.confirm.delete.window.title"),
						Messagebox.YES | Messagebox.NO, Messagebox.QUESTION,
						new EventListener() {
							
							public void onEvent(Event evt) {
								switch (((Integer) evt.getData()).intValue()) {
								case Messagebox.YES:
									try {
										if(eventListener!=null)
											eventListener.onEvent(evt);
									} catch (Exception e) {
										// TODO Auto-generated catch block
//										if(e instanceof BusinessException){
//											BusinessException be = (BusinessException)e;
//											CommonGeneralUtil.throwBussinesException(be);
//										}
										e.printStackTrace();
										log.error(e.getMessage());										
									break; // the Yes button is pressed
								}
							}		
						}
						});
		}catch (Exception e) {
			log.error(e.getMessage());
		}
	
}
	
	public static void throwConfirmMessage(final EventListener callback, String messageConfirm) {
		try{
		StringBuilder message = new StringBuilder();
		message.append(messageConfirm);
		Messagebox.show(
				message.toString(),
				CommonWebUtil
						.getProperty("generic.confirm.message"),
				Messagebox.YES | Messagebox.NO, Messagebox.QUESTION,
				new EventListener() {
					public void onEvent(Event evt) {
						switch (((Integer) evt.getData()).intValue()) {
						case Messagebox.YES:
							try {
								if(callback!=null){
									callback.onEvent(evt);
								}
							} catch (Exception e) {
								e.printStackTrace();
								log.error(e.getMessage());
							}
							break; // the Yes button is pressed
						}
					}
				});
		}catch (Exception e) {
			log.error(e.getMessage());
		}
	}
	public static void throwConfirmCancelMessage(final EventListener callback) {
		try{
		StringBuilder message = new StringBuilder();
		message.append(CommonWebUtil.getProperty("generic.confirm.cancel.message"));
		Messagebox.show(
				message.toString(),
				CommonWebUtil
						.getProperty("generic.confirm.cancel.message"),
				Messagebox.YES | Messagebox.NO, Messagebox.QUESTION,
				new EventListener() {
					public void onEvent(Event evt) {
						switch (((Integer) evt.getData()).intValue()) {
						case Messagebox.YES:
							try {
								if(callback!=null){
									callback.onEvent(evt);
								}
							} catch (Exception e) {
								e.printStackTrace();
								log.error(e.getMessage());
							}
							break; // the Yes button is pressed
						}
					}
				});
		}catch (Exception e) {
			log.error(e.getMessage());
		}
	}
	
	public static void throwConfirmMessageAndBack() {
		try{
		StringBuilder message = new StringBuilder();
		message.append(CommonWebUtil.getProperty("generic.confirm.volver.message"));

		Messagebox.show(
				message.toString(),
				CommonWebUtil
						.getProperty("generic.confirm.volver.title"),
				Messagebox.YES | Messagebox.NO, Messagebox.QUESTION,
				new EventListener() {
					public void onEvent(Event evt) {
						switch (((Integer) evt.getData()).intValue()) {
						case Messagebox.YES:
//							CommonWebUtil.back();
							break; // the Yes button is pressed
						}
					}
				});
		}catch (Exception e) {
			log.error(e.getMessage());
		}
	}
	
	public static void throwSuccessMassage(String successMassageString){
		if(StringUtil.isNullOrEmpty(successMassageString))
			successMassageString = CommonWebUtil.getProperty("generic.success.message");

		String successTitle = "generic.success.title";

		try {
			Messagebox.show(successMassageString, CommonWebUtil
					.getProperty(successTitle), Messagebox.OK,
					Messagebox.INFORMATION, null);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static void throwSuccessMassage(String successMassage, String successTitle, EventListener callback){
		if(StringUtil.isNullOrEmpty(successMassage))
			successMassage = "generic.success.message";
		if(StringUtil.isNullOrEmpty(successTitle))
			successTitle = "generic.success.title";

		try {
			Messagebox.show(CommonWebUtil.getProperty(successMassage), CommonWebUtil
					.getProperty(successTitle), Messagebox.OK,
					Messagebox.INFORMATION, callback);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static void throwErrorMassage(String successMassage, String successTitle, EventListener callback){
		if(StringUtil.isNullOrEmpty(successMassage))
			successMassage = "generic.success.message";
		if(StringUtil.isNullOrEmpty(successTitle))
			successTitle = "generic.success.title";

		try {
			Messagebox.show(CommonWebUtil.getProperty(successMassage), CommonWebUtil
					.getProperty(successTitle), Messagebox.OK,
					Messagebox.ERROR, callback);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
//	public static ServletContext getServletContext(){
//		if (Executions.getCurrent()!=null) {
//			return (ServletContext)Executions.getCurrent().getDesktop().getWebApp().getNativeContext();
//		}else{
//			return ServletContextUtil.getServletContext();
//		}
//	}
	
//	public static ReportProperties getPropertyReport(String property)  {
//		Map<String, ReportProperties> mapReportProperties = (Map<String, ReportProperties>)Executions.getCurrent().getDesktop().getAttribute(CommonWebUtil.REPORT_PROPERTIES);
//		try {
//		if(mapReportProperties==null){
//			mapReportProperties = new HashMap<String,ReportProperties>();
//			ServletContext serverContext= (ServletContext)Executions.getCurrent().getDesktop().getWebApp().getNativeContext(); 
//			BufferedReader bufReader = new BufferedReader(new InputStreamReader(serverContext.getResourceAsStream(CommonWebUtil.PATHMACROS + CommonWebUtil.CONFIGREPORT)));		
//			String prop = null;
//			
//				while ((prop = bufReader.readLine()) != null) {
//					int begin = prop.indexOf("=");
//					if (prop.startsWith("#") || prop.startsWith("!") || begin == -1)
//						continue;			
//					final String key = prop.substring(0, begin).trim();
//					final String values = prop.substring(begin + 1, prop.length()).trim();
//					final String[] vals = values.split(",");
//					if (vals.length == 0)
//						continue;
//					ReportProperties reportProperties = new ReportProperties();
//					reportProperties.setNombre(vals[0].trim());
//					reportProperties.setDescripcion(vals[1].trim());
//					reportProperties.setPath(vals[2].trim());
//					mapReportProperties.put(key, reportProperties);
//				}		
//			Executions.getCurrent().getDesktop().setAttribute(CommonWebUtil.REPORT_PROPERTIES, mapReportProperties);		
//		}				
//		} catch (IOException e) {			
//			e.printStackTrace();
//			log.error(e.getMessage());
//		}
//		return mapReportProperties.get(property);
//	}

	
//	public static DestinationProperties getPropertyDestination(String property)  {
//		Map<String, DestinationProperties> mapDestinationProperties = (Map<String, DestinationProperties>)Executions.getCurrent().getDesktop().getAttribute(CommonWebUtil.DESTINATION_SESSION_KEY);
//		try {
//		if(mapDestinationProperties==null){
//			mapDestinationProperties = new HashMap<String,DestinationProperties>();
//			ServletContext serverContext= (ServletContext)Executions.getCurrent().getDesktop().getWebApp().getNativeContext(); 
//			BufferedReader bufReader = new BufferedReader(new InputStreamReader(serverContext.getResourceAsStream(CommonWebUtil.PATHMACROS + CommonWebUtil.CONFIGDESTINATION)));		
//			String prop = null;
//			
//				while ((prop = bufReader.readLine()) != null) {
//					int begin = prop.indexOf("=");
//					if (prop.startsWith("#") || prop.startsWith("!") || begin == -1)
//						continue;			
//					final String key = prop.substring(0, begin).trim();
//					final String values = prop.substring(begin + 1, prop.length()).trim();
//					final String[] vals = values.split(",");
//					if (vals.length == 0)
//						continue;
//					DestinationProperties destinationProperties = new DestinationProperties();
//					destinationProperties.setDestinationKey(key);
//					destinationProperties.setSubMenuSelect(vals[0].trim());
//					destinationProperties.setWindowDestination(vals[1].trim());					
//					mapDestinationProperties.put(key, destinationProperties);
//				}		
//			Executions.getCurrent().getDesktop().setAttribute(CommonWebUtil.DESTINATION_SESSION_KEY, mapDestinationProperties);		
//		}				
//		} catch (IOException e) {			
//			e.printStackTrace();
//			log.error(e.getMessage());
//		}
//		return mapDestinationProperties.get(property);
//	}

//	public static Object getSelectedObjectFromImage(ForwardEvent event) {
//
//		return ((ValueImage) event.getOrigin().getTarget()).getValue();
//	}
//	
//	public static ValueImage getValueImagetFromImage(ForwardEvent event) {
//
//		return ((ValueImage) event.getOrigin().getTarget());
//	}

	public static void forwardToMe(
			String nextUrl,
			AbstractNavigationComposer composerCurrent) {
		redirecToUrl(getProperty("paginaBlanco"));		
		forward(nextUrl, composerCurrent);
	}
	
	public static void backToMe(String backUrl) {
		redirecToUrl(getProperty("paginaBlanco"));		
		Flow flow = (Flow)Executions.getCurrent().getDesktop().getAttribute(Flow.class.getSimpleName());
		FlowStep step = flow.pop();
		if(step!=null){
			flow.setCurrentStep(step);		
			redirecToUrl(step.getUrl());	
		}
		else{
//			backToSelectMenu();
		}
	}
		
	
	public static Boolean validateAbstractPersistentObject(BaseBO object){
		if(object!=null && object.getId()!=null && object.getId().longValue()>0){
			return true;
		}
		else 
			return false;
	}
	


	
}